const loger = require("../module/loger"), web = require("../module/web");

module.exports.run = (data, c) => {
	global.sdObj.ud = JSON.parse(data.json.toString());
	web.rmcookie();
	if(global.sdObj.ud[4]){ //有vpn就拨号
		const exec = require('child_process').exec;
		exec(__dirname+"/vpn.bat " + global.sdObj.ud[4], (error, stdout, stderr)=>{
			global.sdObj.finish = 1;
			loger.info("vpn end");
			if(error) {
				loger.info("vpn error ", error);
				global.sdObj.end = 1018;
				return;
			}
			
			if(stdout.toString().indexOf("netcfg.chm") > 0)
			{
				global.sdObj.end = 1018;
			}
		});
	}else{
		global.sdObj.finish = 1;
		loger.info("vpn end");
	} 
};
